package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.dto.FamilyMemberDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.LoginVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;
    // 在 FamilyMemberController 或其他合适的类中定义
    private static final ThreadLocal<LoginVo> LOGIN_THREAD_LOCAL = new ThreadLocal<>();


    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo vo = familyMemberService.login(dto);

        // 将登录信息存入 ThreadLocal
        LOGIN_THREAD_LOCAL.set(vo);

        return success(vo);
    }


    /**
     * 新增老人家属
     */
    @PostMapping("/add")
    public AjaxResult addFamily(@RequestBody FamilyMemberDto familyMemberDto){
        familyMemberService.insertFamilyMemberElder(familyMemberDto);

        return AjaxResult.success("操作成功");

    }

//    /**
//     * 获取老人家属列表
//     */
//    @GetMapping("/my")
//    public AjaxResult getList(){
//
//    }
}
